package com.bingsum.util;

import java.io.IOException;
import java.util.Date;

import org.codehaus.jackson.JsonGenerator;
import org.codehaus.jackson.JsonProcessingException;
import org.codehaus.jackson.map.JsonSerializer;
import org.codehaus.jackson.map.SerializerProvider;
import org.springframework.stereotype.Component;


/**
 * 将返回的JSON格式中，日期类型转化为字符串类型，用于前台显示
 * @author LiuXianTing
 *
 */
@Component
public class JsonDateSerializer extends JsonSerializer<Date> {
	
	long time;

	public long getTime() {
		return time;
	}

	public void setTime(long time) {
		this.time = time;
	}

	@Override
	public void serialize(Date date, JsonGenerator jsonGenerator,
			SerializerProvider serializerProvider) throws IOException,
			JsonProcessingException {
		jsonGenerator.writeString(DateHelper.dateToString(date));
	}

}
